#include <bits/stdc++.h>

using namespace std;
#define int long long 
int m, n;
const int N = 105;
signed main(){
	#ifndef ONLINE_JUDGE
	//	freopen("C:\\Users\\29842\\Desktop\\lqq1.in","r",stdin);
	//	freopen("C:\\Users\\29842\\Desktop\\lqq1.out","w",stdout);
	#endif
	scanf("%lld", &m);
	while (m--) {
		scanf("%lld", &n);
		int ans =  0;
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			scanf("%lld", &a[i]);
		}
		sort(a.begin(),a.end());
		for (int i = 1; i <= n; i++)
	    for(int i = 0; i < n; i++){
			ans = max(ans, (n - i) * a[i]);
		}
		cout << ans << '\n';
	}
	return 0;
}
